{extend name="public/base"/}
{block name="style"}
{/block}
{block name="content"}
<div class="out-list">
    <div class="layui-row">
        <div class="layui-inline">
            <input type="text" class="layui-input" autocomplete="off" autofocus="autofocus" id="order-sn" placeholder="借用单号">
        </div>
        <div class="layui-inline">
            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal btn-search"><i class="layui-icon layui-icon-search"></i></button>
        </div>
    </div>
    <div class="data">
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['layer', 'jquery', 'longli'], function()
    {
        var layer = layui.layer
            , $ = layui.jquery;
        $("#order-sn").keydown(function(event)
        {
            if(event.keyCode != 13) return;
            $(".btn-search").click();
            $(this).val('');
        });

        $(".btn-search").click(function()
        {
            var $input = $("#order-sn")
                , sn = $input.val().trim();
            if(!sn) return false;
            $.post("{:url('borrow')}", {sn}).done(function(response)
            {
                var icon = response.code == 1 ? 6 : 5
                msg = !response.msg ? '出库失败' : response.msg;
                layer.msg(msg, {icon: icon, time: 1500});
                if(response.data.type) layui.longli.playMP3(response.data.type);
                if(response.data.html) $(".data").html(response.data.html);
            });
        });
    });
</script>
{/block}